package com.zdlee.netty.server17.server.handler;

import com.zdlee.netty.server17.protocol.request.LogoutRequestPacket;
import com.zdlee.netty.server17.protocol.response.LogoutResponsePacket;
import com.zdlee.netty.server17.util.SessionUtil;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @author zdlee
 * @description: ${DESCRIPTION}
 * @create 2018-12-01 14:11
 */
public class LogoutRequestHandler extends SimpleChannelInboundHandler<LogoutRequestPacket> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, LogoutRequestPacket msg) throws Exception {
        SessionUtil.unBindSession(ctx.channel());
        LogoutResponsePacket logoutResponsePacket=new LogoutResponsePacket();
        logoutResponsePacket.setSuccess(true);
        ctx.channel().writeAndFlush(logoutResponsePacket);

    }
}
